<?php
namespace app\controllers;

use app\filters\ParamAuth;
use yii\web\UnauthorizedHttpException;

class QunitController extends AjaxController {	
	public function actionNeedUser() {
		$param = \Yii::$app->request->headers->get('access-token', null);
		if (!empty($param)) {
			return ['status' => 0];
		} else {
			throw new UnauthorizedHttpException('You are requesting with an invalid credential');
		}
	}
	
	public function actionNoUser() {
		return ['status' => 0];
	}
	
	public function actionTokenExpires() {
		throw new UnauthorizedHttpException('You are requesting with an invalid credential');
	}
	
	public function actionTest() {
		$data = \Yii::$app->request->post('data');
		return ['status' => 0, 'data' => $data];
	}
}